package com.wilmer.consultants_order.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wilmer.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.consultants_order.domain.BankConsultantsOrder;
import com.wilmer.consultants_order.service.IBankConsultantsOrderService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 顾问订单Controller
 * 
 * @author hans
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/consultants_order/order")
public class BankConsultantsOrderController extends BaseController
{
    @Autowired
    private IBankConsultantsOrderService bankConsultantsOrderService;

    /**
     * 查询顾问订单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BankConsultantsOrder bankConsultantsOrder)
    {
        startPage();
        List<BankConsultantsOrder> list = bankConsultantsOrderService.selectBankConsultantsOrderList(bankConsultantsOrder);
        return getDataTable(list);
    }

    /**
     * 导出顾问订单列表
     */
    @PreAuthorize("@ss.hasPermi('consultants_order:order:export')")
    @Log(title = "顾问订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankConsultantsOrder bankConsultantsOrder)
    {
        List<BankConsultantsOrder> list = bankConsultantsOrderService.selectBankConsultantsOrderList(bankConsultantsOrder);
        ExcelUtil<BankConsultantsOrder> util = new ExcelUtil<BankConsultantsOrder>(BankConsultantsOrder.class);
        util.exportExcel(response, list, "顾问订单数据");
    }

    /**
     * 获取顾问订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('consultants_order:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bankConsultantsOrderService.selectBankConsultantsOrderById(id));
    }


    @PutMapping(value = "/{orderNum}")
    public AjaxResult updateOrder(@PathVariable("orderNum") String orderNum)
    {
        return success(bankConsultantsOrderService.updateOrder(orderNum));
    }

    /**
     * 新增顾问订单
     */
    @PreAuthorize("@ss.hasPermi('consultants_order:order:add')")
    @Log(title = "顾问订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankConsultantsOrder bankConsultantsOrder)
    {
        return toAjax(bankConsultantsOrderService.insertBankConsultantsOrder(bankConsultantsOrder));
    }

    /**
     * 修改顾问订单
     */
    @PreAuthorize("@ss.hasPermi('consultants_order:order:edit')")
    @Log(title = "顾问订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankConsultantsOrder bankConsultantsOrder)
    {
        return toAjax(bankConsultantsOrderService.updateBankConsultantsOrder(bankConsultantsOrder));
    }

    /**
     * 删除顾问订单
     */
    @PreAuthorize("@ss.hasPermi('consultants_order:order:remove')")
    @Log(title = "顾问订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bankConsultantsOrderService.deleteBankConsultantsOrderByIds(ids));
    }
}
